package com.pacifictextiles.qc.inspection.server.model.test;

import java.util.LinkedList;
import java.util.List;
import com.pacifictextiles.qc.inspection.server.model.dao.impl.RollDAOImpl;
import com.pacifictextiles.qc.inspection.server.model.vo.Roll;

public class testAddRoll {
	public static void main(String[] args) {
		// new an interface
		RollDAOImpl testRollDAOImpl = new RollDAOImpl();

		// set instance variable of roll
		Roll roll = new Roll();
		roll.setRollNo("83");
		roll.setFullCode("4");
		roll.setExpRollNo("10000");
		roll.setStationId("44");
		roll.setOperatorId("11");
		roll.setDefectCount(0);
		roll.setQualityLevel(0);
		roll.setCpi(0);
		roll.setWpi(0);
		roll.setSpace(0);
		roll.setTotalpoints(0);
		roll.setWidth(0);
		roll.setNetLength(0);
		roll.setGrossLength(0);
		roll.setWasteLength(0);
		roll.setWeightingStatus(false);
		roll.setInspectStatus(false);

		//add OK
		try {
			//testRollDAOImpl.addNewRoll(roll.getFullCode(), roll.getStationId(), roll.getOperatorId());
			
			testRollDAOImpl.finishUpdateRoll(roll);
		} catch (Exception e) {
			e.printStackTrace();
		}

		// delete OK
		try {
			testRollDAOImpl.deleteRoll("");
		} catch (Exception e) {
			e.printStackTrace();
		}

		//get list
		try {
			List<Roll> rollList = new LinkedList<Roll>();

			//get by fullCode
			rollList = testRollDAOImpl.getRollList("5");
			printRolltList(rollList);
			
			// 判断有无查询到结果
			if (rollList.isEmpty()) {
				System.out.print("没有查询到 roll的信息" + "\n");
			}
			
		} catch (Exception e) {
			//e.printStackTrace();
			System.out.print("获取List失败"+"\n");
		}
	}// main method

	private static void printRolltList(List<Roll> rollList) throws Exception {
		int counterMinus = rollList.size() - 1;
		while (counterMinus >= 0) {
			Roll roll_receive = rollList.get(counterMinus);

			System.out.print(roll_receive.getRollNo() + "\n"
					+ roll_receive.getFullCode() + "\n"
					+ roll_receive.getExpRollNo() + "\n"
					+ roll_receive.getStationId() + "\n"
					+ roll_receive.getOperatorId() + "\n"
					+ roll_receive.getDefectCount() + "\n"
					+ roll_receive.getQualityLevel() + "\n"
					+ roll_receive.getCpi() + "\n" + roll_receive.getWpi()
					+ "\n" + roll_receive.getSpace() + "\n"
					+ roll_receive.getTotalpoints() + "\n"
					+ roll_receive.getWidth() + "\n"
					+ roll_receive.getFabricWeight() + "\n"
					+ roll_receive.getTubeWeight() + "\n"
					+ roll_receive.getNetLength() + "\n"
					+ roll_receive.getGrossLength() + "\n"
					+ roll_receive.getWasteLength() + "\n"
					+ roll_receive.getDateAndTime() + "\n"
					+ roll_receive.isInspectStatus() + "\n"
					+ roll_receive.isWeightingStatus() + "\n\n\n");
			counterMinus--;
		}
	}
	

}// public class


